<?php

$api = app('Dingo\Api\Routing\Router');

$api->group([
    'namespace' => 'App\Http\Controllers\Backstage',
    'prefix' => 'backstage',
    'as' => 'backstage',
    'middleware' => ['api.auth', 'cors']
], function ($api) {

    $api->resource('link', 'LinkController');

    $api->resource('label', 'LabelController');

    $api->post('project/upload', ['uses' => 'ProjectController@upload', 'as' => 'project.task.upload']);
//    $api->get('project/downloads/{id}', ['uses' => 'ProjectController@downloads', 'as' => 'project.task.downloads']);
    $api->resource('project', 'ProjectController');

    $api->post('label-task/upload', ['uses' => 'LabelTaskController@upload', 'as' => 'label.task.upload']);
    $api->resource('label-task', 'LabelTaskController');

    $api->group([
        'namespace' => 'Push',
        'prefix' => 'push',
        'as' => 'push'
    ], function ($api) {
        $api->get('file', 'PushController@getFile');
        $api->resource('push', 'PushController');
    });

    $api->group([
        'namespace' => 'Company',
        'prefix' => 'company',
        'as' => 'company'
    ], function ($api) {

        $api->group([
            'namespace' => 'Furniture',
            'prefix' => 'furniture',
            'as' => 'furniture'
        ], function ($api) {
            $api->resource('category', 'CategoryController');
        });

        $api->group([
            'namespace' => 'Task',
            'prefix' => 'task',
            'as' => 'task'
        ], function ($api) {
            $api->post('material/upload', ['uses' => 'MaterialController@upload', 'as' => 'material.upload']);
            $api->resource('material', 'MaterialController');

            $api->post('furniture/upload', ['uses' => 'FurnitureController@upload', 'as' => 'furniture.upload']);
            $api->resource('furniture', 'FurnitureController');
        });

        $api->resource('category', 'CategoryController');
        $api->resource('material', 'MaterialController');
        $api->resource('furniture', 'FurnitureController');
        $api->resource('archive', 'ArchiveController');

        $api->post('task/upload', ['uses' => 'TaskController@upload', 'as' => 'task.upload']);
        $api->get('task/release/{id}', ['uses' => 'TaskController@release', 'as' => 'task.release']);
        $api->resource('task', 'TaskController');
    });

    $api->group([
        'namespace' => 'System',
        'prefix' => 'system',
        'as' => 'system'
    ], function ($api) {
        $api->resource('regions', 'RegionController');
    });

    /**
     * 上传文件
     */
    $api->post('upload', 'UploadController@upload');

    /**
     * 用户管理
     */
    $api->resource('users', 'UserController');

    /**
     * 装修百科
     */
    $api->group([
        'namespace' => 'Encyclopedia',
        'prefix' => 'encyclopedia',
        'as' => 'encyclopedia'
    ], function ($api) {
        /**
         * 分类
         */
        $api->resource('category', 'CategoryController');

        /**
         * 文章管理
         *
         */
        $api->resource('article', 'ArticleController');
    });
});